In this article, you are going to learn How do you prevent a href using javascript?

Remove the href attribute.

The easy way to "disable" a link, you can remove its href attribute so that when someone will click on it,it will not redirect to a new page.

<a class="link" href="https://www.3schools.in">disable link</a>
Remove the href=" " attribute to prevent the link.

How to remove link from anchor tag using CSS

You can easily disable all links on a page with the help of css.

Example

Prevent a href using onclick method.

Example 2